package com.gsafety.wellsfort.domain.vo;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.gsafety.wellsfort.common.enums.CustomerTypeEnum;
import com.gsafety.wellsfort.domain.model.course.Course;
import com.gsafety.wellsfort.domain.model.knowledge.Courseware;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.springframework.beans.BeanUtils;

import java.util.Date;

@Data
@ApiModel(value = "课程")
public class CourseVO {
    private Integer id;

    @ApiModelProperty(value = "课程对象值")
    private Integer objectType;
    @ApiModelProperty(value = "课程对象名称")
    private String objectTypeText;

    @ApiModelProperty(value = "课程名称")
    private String name;

    @ApiModelProperty(value = "课程简介")
    private String introduction;

    @ApiModelProperty(value = "课程图URL")
    private String imageUrl;

    @ApiModelProperty(value = "缩略图URL")
    private String thumbnailUrl;

    @ApiModelProperty(value = "0，线上，1，线下")
    private Byte teachingWay;

    @ApiModelProperty(value = "上线时间")
    private Date attendClassTime;

    @ApiModelProperty(value = "是否上线:1,是.0 否")
    private Integer isOnline;

    @ApiModelProperty(value = "上线时间")
    @JsonFormat(pattern="yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
    private Date onlineTime;

    @ApiModelProperty(value = "课程时长")
    private Integer duration;
    public static  class VOBuilder{
        Course course;
        CourseVO courseVO =new CourseVO();
        public VOBuilder(Course q){
            this.course =q;
        }
        public CourseVO build(){
            BeanUtils.copyProperties(course, courseVO);
            courseVO.setObjectTypeText(CustomerTypeEnum.parseVal(courseVO.getObjectType()).label);
            return courseVO;
        }
    }
}
